1. 安装oracle client 客户端

官网下载zip编译版本或rpm安装包download

1.1 编译版安装 (192.168.8.141)

mkdir -p /home/zabbix/oracle/bin
mkdir -p /home/zabbix/oracle/lib
mkdir -p /home/zabbix/oracle/sdk
mkdir -p /home/zabbix/oracle/network/admin

cd /home/zabbix/soft
unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
cd /home/zabbix/soft/instantclient_12_2
mv adrci uidrvci genezi BASIC_README  /home/zabbix/oracle/bin
mv * /home/zabbix/oracle/lib

cd /home/zabbix/soft
unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
cd /home/zabbix/soft/instantclient_12_2
mv *.so /home/zabbix/oracle/lib
mv * /home/zabbix/oracle/bin

cd /home/zabbix/soft
unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip
cd /home/zabbix/soft/instantclient_12_2/sdk
mv * /home/zabbix/oracle/sdk

cd /home/zabbix/soft
unzip instantclient-tools-linux.x64-12.2.0.1.0.zip
cd /home/zabbix/soft/instantclient_12_2
mv *.so /home/zabbix/oracle/lib/
mv * /home/zabbix/oracle/bin

cd /home/zabbix/soft
unzip instantclient-jdbc-linux.x64-12.2.0.1.0.zip
cd /home/zabbix/soft/instantclient_12_2

1.2 创建别名

vim /home/zabbix/oracle/network/admin/tnsnames.ora

ZBXPRD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.63)(PORT = 1525))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = zbxprd)
    )
  )

1.3 环境变量设置

vim ~/.bash_profile

export ORACLE_HOME=/home/zabbix/oracle
export LD_LIBRARY_PATH=/home/zabbix/oracle/lib
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH=$PATH:$ORACLE_HOME/bin

1.4 测试联通性

sqlplus /nolog
SQL> conn zabbix/abc123456@zbxprd

Oracle学习系列之Client安装

2. zabbix

cd /home/zabbix/soft
tar -xvzf zabbix-3.2.4.tar.gz
cd /home/zabbix/soft/zabbix-3.2.4

#./configure --enable-server --enable-agent --with-oracle=$ORACLE_HOME --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/home/zabbix/zabbix-3.2.4

cd /home/zabbix/oracle/lib
ln -s libocci.so.12.1 libocci.so
ln -s libclntsh.so.12.1 libclntsh.so
ln -s libclntshcore.so.12.1 libclntshcore.so

su root
echo "/home/zabbix/oracle/lib" > /etc/ld.so.conf.d/oracle-client-12.1.conf
ldconfig
yum install libxml2 libxml2-devel net-snmp-devel net-snmp libcurl libcurl-devel
exit

cd /home/zabbix/soft/zabbix-3.2.4
./configure --enable-server --enable-agent --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/home/zabbix/zabbix-3.2.4 --with-oracle-include=/home/zabbix/oracle/sdk/include  --with-oracle-lib=/home/zabbix/oracle/lib
make 
make install 

3. JavaGate安装 (192.168.8.141/192.168.8.142)

#### JavaGate
export JAVA_HOME="/home/zabbix/jdk"
export PATH="$PATH:${JAVA_HOME}/bin/"

./configure --enable-java --prefix=/home/zabbix/zabbix-3.2.4

4.导入脚本时注意点

cd /home/zabbix/soft/zabbix-3.2.4/database/oracle
cp schema.sql schema.raw.sql

sqlplus /nolog
conn zbxapp/abc12345@zbxprd
select * from USER_TABLES;
@schema.sql;
@images.sql;
@data.sql;
select * from USER_TABLES;

4.1 schema.sql需要修改,将其中nvarchar2(2048)都改成nvarchar2(2000),这是12c的限制,最大只能2000

sed -i 's#2048#2000#g' schema.sql

4.2 images.sql需要目录读写权限

SQL> @images.sql;
CREATE OR REPLACE DIRECTORY image_dir AS '/home/zabbix/zabbix/create/output_png'
*
ERROR at line 1:
ORA-01031: insufficient privileges


CREATE OR REPLACE PROCEDURE LOAD_IMAGE (IMG_ID IN NUMBER, IMG_TYPE IN NUMBER, IMG_NAME IN VARCHAR2, FILE_NAME IN VARCHAR2)
*
ERROR at line 1:
ORA-01031: insufficient privileges

赶紧联系DBA给目录授权,但还是不行,原理需要将output_png目录拷贝到数据库服务器上面才行,oracle真实权限限制太复杂.

SQL> @images.sql;

Directory created.

CREATE OR REPLACE PROCEDURE LOAD_IMAGE (IMG_ID IN NUMBER, IMG_TYPE IN NUMBER, IMG_NAME IN VARCHAR2, FILE_NAME IN VARCHAR2)
*
ERROR at line 1:
ORA-01031: insufficient privileges


        LOAD_IMAGE(1,1,'Cloud_(128)','png_modern/Cloud_(128).png');
        *
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "SYS.DBMS_LOB", line 805
ORA-06512: at "ZBXAPPDATA.LOAD_IMAGE", line 8
ORA-06512: at line 2



Procedure dropped.

DROP DIRECTORY image_dir

Buttonwood
17 声望1 粉丝

Float like a butterfly! Stand like a buttonwood!